#!/usr/bin/python

import os
import sys
from hashlib import md5

if len(sys.argv) < 2:
    print "please input file names."
    exit(1)

READ_SIZE = 1024*1024*10

for filename in sys.argv[1:]:
    try:
        md5handler = md5()
        if os.path.isfile(filename) != True:
            print filename + " : not exist."
            continue
        filehandler = open(filename, "rb", -1) # obviously, we use system default
        size = 0
        while True:
            content = filehandler.read(READ_SIZE)
            if len(content) == 0:
                print filename + " : " + md5handler.hexdigest().lower()
                filehandler.close()
                break
            md5handler.update(content)
    except:
        print filename + " : exception occured"
    finally:
        pass

exit(0)

